import { defineStore } from "pinia";
import { getEntireRoles, getEntireDepartments } from "@/api/main/system/system";

interface IMainState {
  entireRoles: any[];
  entireDepartments: any[];
}
const useMainStore = defineStore("main", {
  state: (): IMainState => ({
    entireRoles: [],
    entireDepartments: [],
  }),
  actions: {
    async fetchEntireDataAction() {
      const rolesResult = await getEntireRoles();
      const departmentsResult = await getEntireDepartments();
      
      // 保存数据
      this.entireRoles = rolesResult.data.list;
      this.entireDepartments = departmentsResult.data.list;
      // console.log(rolesResult, departmentsResult);
    },
  },
});

export default useMainStore;
